package com.yuqingxin.redisCacheApi.common.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 自定义接口返回格式类
 * */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private Integer code;

    private String message;

    private T data;

    public static <T> Result<T> success(T data){
        return new Result<>(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMessage(), data);
    }

    public static <T> Result<T> result(ResultEnum resultEnum, T data){
        return new Result<>(resultEnum.getCode(),resultEnum.getMessage(),data);
    }
}
